#ifndef DETECTIONRESULT_H
#define DETECTIONRESULT_H

#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonParseError>
#include <QObject>
#include "controlcommand.h"
#include "defectinfo.h"

/**
 * @brief The DetectionResult class ,for JSON
 */
class DetectionResult : public QObject
{
    Q_OBJECT
public:
    DetectionResult();
    ~DetectionResult();

private:
    ControlCommand info;
    QList<DefectInfo> result;

public:
    void SetInfo(ControlCommand &info);
    void SetResult(QList<DefectInfo> &result);

    void AppendDefectInfo(DefectInfo di){
        result.append(di);
    }

    ControlCommand &GetInfo();
    QList<DefectInfo> &GetResult();

    DetectionResult &operator=(DetectionResult &other)
    {
        this->info = other.info;
        this->result = other.result;
        return *this;
    }

public:
    bool fromJson(const QString &json);
    QString toJson() const;
};

#endif // DETECTIONRESULT_H
